<?php

namespace App\Models;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;

class Orders extends Model
{
    public $timestamps = true;

    protected $table = 'orders';


    /**
     * 为数组 / JSON 序列化准备日期。
     *
     * @param \DateTimeInterface $date
     * @return string
     */
    protected function serializeDate(\DateTimeInterface $date)
    {
        return Carbon::instance($date)->toDateTimeString();
    }
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'order_sn', 'transaction_sn','courier_sn','user_id','goods_id','goods_name','goods_num','goods_cover','goods_prices','status','status_msg','prices','total_price','user_name','user_mobile','shipping_address','bank_type','prepay_id','pay_at','refund_at'
    ];


    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     * 获取商品信息
     */
    public function goods()
    {
        return $this->hasOne(Goods::class , 'id' , 'goods_id');
    }
}
